//
// Created by konglinglong on 2020/9/24.
//

#include <stdio.h>
#include <iostream>
#include "../lib/doctest.h"
#include "../../include/osal/osThread.h"

static void UT_ThreadEntry(void *arg)
{
    while (1)
    {
        sleep(1);
        pthread_testcancel();
    }
}

TEST_SUITE ("OS_THREAD_TS")
{
    TEST_CASE ("OS_THREAD_TC")
    {
        int32_t rc;
        pthread_t tid;
        SUBCASE("OS_THREAD_SC_BASE")
        {
            rc = OS_ThreadCreate(&tid, (os_thread_routine)UT_ThreadEntry, NULL);
            REQUIRE(CSP_RC_OK == rc);
            rc = OS_ThreadCancel(tid);
            REQUIRE(CSP_RC_OK == rc);
        }
    }
}
